package com.gj.demojuc.chap09;

import java.util.concurrent.atomic.AtomicInteger;

public class AtomicDemo {
    public static void main(String[] args) {
        AtomicInteger atomicInteger = new AtomicInteger(1);

        System.out.println("第一次更新："+atomicInteger.compareAndSet(1,200));
        System.out.println("第一次更新后i的值："+atomicInteger.get());

        System.out.println("第二次更新：" + atomicInteger.compareAndSet(1, 300));
        System.out.println("第二次更新后i的值：" + atomicInteger.get());

        System.out.println("第三次更新：" + atomicInteger.compareAndSet(200, 300));
        System.out.println("第三次更新后i的值：" + atomicInteger.get());
    }
}
